namespace JQuery.WebKit
{
    using System;
    using System.Security.Permissions;
    using System.Web;

    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    public class WebGridDataRequestEventArgs : EventArgs
    {
        private int _newPageIndex;
        private string _parentRowKey;
        private string _searchExpression;
        private JQuery.WebKit.SortDirection _sortDirection;
        private string _sortExpression;
        private int _totalRows;

        public WebGridDataRequestEventArgs(string sortExpression, string sortDirection, int newPageIndex, string searchExpression, string parentRowKey)
        {
            this._sortExpression = sortExpression;
            this._newPageIndex = newPageIndex;
            this._searchExpression = searchExpression;
            this._parentRowKey = parentRowKey;
            if (sortDirection == null)
            {
                sortDirection = string.Empty;
            }
            this._sortDirection = (sortDirection.ToLower() == "asc") ? JQuery.WebKit.SortDirection.Asc : JQuery.WebKit.SortDirection.Desc;
        }

        public int NewPageIndex
        {
            get
            {
                return this._newPageIndex;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("value");
                }
                this._newPageIndex = value;
            }
        }

        public string ParentRowKey
        {
            get
            {
                return this._parentRowKey;
            }
            set
            {
                this._parentRowKey = value;
            }
        }

        public string SearchExpression
        {
            get
            {
                return this._searchExpression;
            }
            set
            {
                this._searchExpression = value;
            }
        }

        public JQuery.WebKit.SortDirection SortDirection
        {
            get
            {
                return this._sortDirection;
            }
            set
            {
                this._sortDirection = value;
            }
        }

        public string SortExpression
        {
            get
            {
                return this._sortExpression;
            }
            set
            {
                this._sortExpression = value;
            }
        }

        public int TotalRows
        {
            get
            {
                return this._totalRows;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("value");
                }
                this._totalRows = value;
            }
        }
    }
}

